package com.socialbank.web.controller;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.socialbank.web.util.HttpUtils;
import com.socialbank.web.util.SocialBankUtils;

@Controller
@RequestMapping("/bank/user")
public class BankUserController{
	
	/**
	 * 客户列表
	 * @return
	 */
	@RequestMapping("/toUserList")
	public String toUserList(){
		return "customerManager/ListCustomer";
	}
	
	/**
	 * 客户统计
	 * @return
	 */
	@RequestMapping("/toUserStatistics")
	public String toUserStatistics(){
		return "customerManager/statisticsCustomer";
	}
	
	/**
	 * 绑定的用户 status bind 绑定用户 notBind 未绑定用户
	 * @param status
	 * @return
	 */
	@RequestMapping("/card")
	public @ResponseBody Object listUserBindCard(String status) {
		Map<String, Object> map = new HashMap<String,Object>();
		if(StringUtils.isNoneBlank(status)){
			map.put("status", status);
		}
		String result = HttpUtils.get(map , SocialBankUtils.BANK_USER_CARD);
		if(StringUtils.isNoneBlank(result)){
			return result;
		}else{
			return new HashMap<>();
		}
	}
	
	/**
	 * 统计用户数量
	 * @param map
	 * @return
	 */
	@RequestMapping("/countUser")
	public @ResponseBody Object countUser(@RequestBody Map<String, Object> map) {
		String result = HttpUtils.postWithJSON(map, SocialBankUtils.BANK_USER_COUNT);
		if(StringUtils.isNoneBlank(result)){
			return result;
		}else{
			return new HashMap<>();
		}
	}
	
	/**
	 * 统计用户数量 按照给定范围
	 * @param map
	 * @return
	 */
	@RequestMapping("/day")
	public @ResponseBody Object countBindCardByDay(@RequestBody Map<String, Object> map) {
		String result = HttpUtils.postWithJSON(map, SocialBankUtils.BANK_USER_COUNT_DAY);
		if(StringUtils.isNoneBlank(result)){
			return result;
		}else{
			return new HashMap<>();
		}
	}
	@RequestMapping("/month")
	public @ResponseBody Object countBindCardByMonth() {
		String result = "这是不错的";
		if(StringUtils.isNoneBlank(result)){
			return result;
		}else{
			return new HashMap<>();
		}
	}
	
}
